#pragma once

class Board
{
private:
	int data[20][20];
	int remain = 121;

public:
	Board()
	{
		memset(data, 0, sizeof(data));
	}

	Board(const Board & board)
	{
		memcpy(data, board.data, sizeof(board.data));
	}

	int get(int pos) const
	{
		if (pos < 0 || pos >= 11 * 11)
		{
			throw std::exception();
		}

		return get(pos / 11, pos % 11);
	}

	int get(int x, int y) const
	{
		if (x < 0 || x >= 11)
		{
			return 1;
		}
		if (y < 0 || y >= 11)
		{
			return 2;
		}

		return data[x][y];
	}

	void set(int x, int y, int val)
	{
		if (x < 0 || x >= 11 || y < 0 || y >= 11)
		{
			throw std::exception();
		}

		if (data[x][y] == 0 && val != 0) {
			remain--;
		}
		else if (data[x][y] != 0 && val == 0) {
			remain++;
		}
		data[x][y] = val;
	}

	void set(int pos, int val)
	{
		set(pos / 11, pos % 11, val);
	}

	int * ptr() {
		return reinterpret_cast<int*>(data);
	}

	int rem() {
		return remain;
	}
};